package com.jch.dm.chapter_23_interpreter;

/**
 * @author: Administrator
 * <command> ::= <repeat command> | <primitive command>
 * @create: 2020/04/14 18:21
 **/
public class CommandNode extends Node {

    private Node node;


    /**
     * 解析
     *
     * @param context
     * @throws ParseException
     */
    @Override
    public void parse(Context context) throws ParseException {
        if (context.currentToken().equals("repeat")){
            node = new RepeatCommandNode();
            node.parse(context);
        }else {
            node = new PrimitiveCommandNode();
            node.parse(context);
        }
    }

    @Override
    public String toString(){
        return node.toString();
    }
}
